#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time: 2022/12/27 21:18
# @Author: 张磊
# @Email: 1273104996@qq.com
# @File：recommend_page.py
from pages.base_page import BasePage
from appium.webdriver.common.mobileby import MobileBy as By

class Recommend(BasePage):
    # 推荐页面社区精选作品定位器
    community_works_locator = (By.XPATH, "//android.widget.TextView[@resource-id=\"com.gfeng.daydaycook:id/title\" and @text=\"新版食谱专栏活动试运行，征集会做菜的你！\"]")
    # 精选作品评论定位器
    community_comment_locator = (By.ID, "com.gfeng.daydaycook:id/tv_comment")
    # 精选作品点赞定位器
    community_like_locator = (By.ID, "com.gfeng.daydaycook:id/like_imageview")
    # 精选作品收藏定位器
    community_collect_locator = (By.ID, "com.gfeng.daydaycook:id/iv_collection")
    # 精选作品输入框定位器
    community_input_locator = (By.ID, "com.gfeng.daydaycook:id/et_comment")
    # 精选作品评论发送定位器
    community_send_locator = (By.ID, "com.gfeng.daydaycook:id/tv_commit")

    # 点击推荐页面社区精选的作品
    def click_community_works(self):
        self.driver.find_element(*self.community_works_locator).click()
    # 点击作品评论
    def click_community_comment(self):
        self.driver.find_element(*self.community_comment_locator).click()
    # 点击作品点赞
    def click_community_like(self):
        self.driver.find_element(*self.community_like_locator).click()
    # 点击作品收藏
    def click_community_collect(self):
        self.driver.find_element(*self.community_collect_locator).click()
    # 点击作品输入框
    def community_input_comment(self,comment):
        self.driver.find_element(*self.community_input_locator).send_keys(comment)
    # 点击作品评论发送
    def click_community_send(self):
        self.driver.find_element(*self.community_send_locator).click()